# Contributor: vinymeuh <vinymeuh@gmail.com>
# Maintainer: Luca Weiss <luca@lucaweiss.eu>
pkgname=libgpiod
pkgver=2.2
pkgrel=0
pkgdesc="C library and tools for interacting with the linux GPIO character device"
url="https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/"
arch="all"
license="LGPL-2.1-or-later"
options="!check" # no test suite
makedepends="
	autoconf
	autoconf-archive
	automake
	doxygen
	help2man
	libtool
	linux-headers
	py3-build
	py3-pip
	python3-dev
	"
subpackages="$pkgname-dev $pkgname-doc py3-$pkgname:_py3"
source="https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/snapshot/libgpiod-$pkgver.tar.gz"

prepare() {
	default_prepare
	autoreconf -vfi
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-tools=yes \
		--disable-static \
		--enable-bindings-python
	make
}

package() {
	make DESTDIR="$pkgdir" install
}

_py3() {
	pkgdesc="Python bindings for libgpiod"
	depends="python3"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/
}

sha512sums="
41e7a2b8cbd6f5766f34134c589876b6130bb3a5143be6868e8d2d6c7522ef7d5b78bf2d95da873451b82ad5abaaff2f92d61bb86e53634cf683230006612952  libgpiod-2.2.tar.gz
"
